下沒有運行雖然我明白了爲什麼IM接收到錯誤NSInvalidArgumentException錯誤。 UIUserInterfaceIdiomPad
',原因是:「 - [UIPopoverController initWithContentViewController:]調用時UIUserInterfaceIdiomPad下不運行」
整頓它變得有點棘手。我的彈出窗口只需要在ipad上,而不是在iphone版本上。我省略了iphones if statement
的任何代碼,但仍然崩潰。 。假設我必須調用iphone上的視圖以及其通用應用程序,我只需在if iphone statement
中調用該筆尖即可,而且這也不起作用。
- (IBAction)popZs:(id)sender {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if ([popoverController isPopoverVisible]) {
[popoverController dismissPopoverAnimated:YES];
} else {
[self->popoverController setPopoverContentSize: CGSizeMake(601, 571)];
[popoverController presentPopoverFromRect:((UIButton *)sender).bounds
inView:sender
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
}
else {
/////using iPhone/////not sure how to handle this spart
zsTablePop *pop = [[zsTablePop alloc] init];
pop.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[pop presentModalViewController:pop animated:YES];
}
不斷得到即使使用if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
創造流行的IM一樣erorr超過
.m
#import "ICCircuitDetails.h"
#import "zsTablePop.h" ///////////////pop over xib/////
@interface ICCircuitDetails()
{
zsTablePop *controller;
UIPopoverController *popoverController;
}
///////more code/////////////
- (id)initWithCircuit:(Circuit *)circuit
{
self = [super initWithCertificate:circuit.distributionBoard.certificate];
if (self) {
self.circuit = circuit;
[[NSBundle mainBundle] loadNibNamed:@"ICCircuitDetails" owner:self options:nil];
self.view.contentSize = CGSizeMake(self.contentView.frame.size.width, self.contentView.frame.size.height);
///////////other code here/////////////////
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
controller = [[zsTablePop alloc] initWithNibName:@"zsTablePop" bundle:nil];
popoverController = [[UIPopoverController alloc] initWithContentViewController:controller];
如果您嘗試記錄當前設備成語,您會看到什麼? – shortstuffsushi
它應該是[self presentModalViewController:pop animated:YES]; – Moxy
@Moxy,我雖然那樣,但我得到了一個沒有'@界面錯誤'別的是聲明'現在的模態視圖動畫' – JSA986