ShowViewController在PopViewController拿值。注意設置代理(委托)?就像,我沒有委拖你替我辦事,你去銀行,或者去政府替我辦事,人家當然不會處理你
(1)PopViewController.h
#import
//定義協議 -(void)passPopReport:(NSString*)string; @end @interface PopViewController : UIViewController @property(nonatomic,retain)NSObject - (IBAction)reportAction:(UIButton *)sender; @end (2)PopViewController.m - (IBAction)reportAction:(UIButton *)sender { [self.popDeleage passPopReport:@"舉報"];//賦值 } (3)ShowViewController.h遵守協議popNextDeleage UIView *moreView; } (4)ShowViewController.m //實現協議(拿到值) if ([string isEqualToString:@"舉報"]) { (5)ShowViewController.m設置deleage -(void)pop:(id)sender{ PopViewController *pop = [[PopViewController alloc] init]; }
@protocol popNextDeleage
@interface ShowViewController : UIViewController
-(void)passPopReport:(NSString *)string{
ReportViewController *report = [[ReportViewController alloc] init];
[self.navigationController pushViewController:report animated:YES];
}
}
pop.popDeleage = self;//設置deleage(誰實現了delegate方法就指定給誰)
FPPopoverController *basePop = [[FPPopoverController alloc] initWithViewController:pop];
basePop.tint = FPPopoverLightGrayTint;
basePop.arrowDirection = FPPopoverArrowDirectionAny;
[basePop presentPopoverFromView:sender];