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