你好,伙计们,我已经使用 UIButton 作为 UILabel 的子视图,我在单击该按钮时打开了一些弹出窗口,我发现弹出窗口正在远离该按钮打开它背后的原因是什么,请帮助.. 谢谢!我的代码如下:
sortBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[sortBtn setTitle:@"Sort" forState:UIControlStateNormal];
[sortBtn setBackgroundColor:[UIColor colorWithRed:0.137 green:0.384 blue:0.871 alpha:1.0]];
[sortBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:16.0f]];
[sortBtn addTarget:self action:@selector(sortTheData:) forControlEvents:UIControlEventTouchUpInside];
sortBtn.frame=CGRectMake(195,5, 53, 28);
[categoryLabel setUserInteractionEnabled:YES];
[categoryLabel addSubview:sortBtn];
排序数据方法如下:
SortByController *sortController = [[SortByController alloc] initWithNibName:@"SortByController" bundle:nil];
sortController.dataArray = self.dataAllPerformances;
sortController.sortString =self.sortString;
sortController.genreId = [NSString stringWithFormat:@"%d",self.genreId];
sortController._delegate = self;
self.popController = [[UIPopoverController alloc] initWithContentViewController:sortController];
//popController.delegate = self;
popController.popoverContentSize = CGSizeMake(230, 260);
[popController presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[sortController release];