当使用tabBarController做为根视图控制器的时候,通过一个按钮在这个视图控制器上加一个UIActionSheet的时候,我们会出现一个小错误,这个小错误可能使UIActionSheet不能正常使用。
Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].
我们需要做出如下改动:
-(void)sharedClicked:(UIButton *)button{
UIActionSheet *sheet = [[UIActionSheetalloc]initWithTitle:@"分享"delegate:nilcancelButtonTitle:@"取消"destructiveButtonTitle:nilotherButtonTitles:@"分享到新浪",@"分享到朋友圈",@"分享到微信",nil];
[sheet showFromTabBar:self.tabBarController.tabBar];
// [sheetshowInView:self.view];
}
将[sheet showInView : self . view ];改为[sheet showFromTabBar:self.tabBarController.tabBar];这样UIActionSheet就可以正常使用了。