在 XCode 里面,點(diǎn) Show the Breakpoint navigator 按鈕,在左下角有一個(gè)加號(hào),點(diǎn)加號(hào),然后點(diǎn) Add Exception Breakpoint 和 Add Swift Error Breakpoint。然后重新編譯執(zhí)行項(xiàng)目,貼報(bào)錯(cuò)上來(lái)。
公司主營(yíng)業(yè)務(wù):網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。創(chuàng)新互聯(lián)推出喀喇沁免費(fèi)做網(wǎng)站回饋大家。
這是因?yàn)槟愕膙iewcontroller 繼承了UIViewController.而UIViewController 繼承自oc的NSObject. 在swift 中被修飾成@objc class. 那么就必須要遵循oc的selector,在oc中是不支持方法重載的。所以會(huì)報(bào)上面的錯(cuò)誤
如果要解決這種問(wèn)題有兩種方法
1. 刪除繼承自oc的類
2. 其中一個(gè)方法重命名
你的這種情況,顯然第一種方法不合適,你的控制器還是需要繼承自u(píng)iviewcontroller,那么只能用第二種方法,對(duì)這個(gè)方法進(jìn)行重命名。
參考:
其實(shí)就是想知道怎么開(kāi)發(fā)ios的app吧?
首先, 不要倔強(qiáng), 你需要付出99$購(gòu)買開(kāi)發(fā)者賬號(hào), 需要一臺(tái)測(cè)試用的iphone/ipad, 最好有一臺(tái)mac電腦.
然后, 你會(huì)購(gòu)買賬號(hào)之后, 那個(gè)買賬號(hào)的網(wǎng)站會(huì)把這些問(wèn)題的答案全部告訴你.
最后, 你問(wèn)題比較多, 就不詳細(xì)描述了, 有耐心的話, 那個(gè)網(wǎng)站會(huì)把所有的告訴你
首先我們要打開(kāi)手機(jī),然后從iPhone手機(jī)的底部向上滑動(dòng),調(diào)出“控制中心”頁(yè)面,然后點(diǎn)擊右上方的“轉(zhuǎn)屏”按鈕,關(guān)閉“豎排方向鎖定”。
iPhone手機(jī)調(diào)用科學(xué)計(jì)算器
第二步:這時(shí)我們的手機(jī)就可以橫豎自由旋轉(zhuǎn)了,接下來(lái)在“附加程序”中找到“計(jì)算器”并打開(kāi),這時(shí)我們看到的還是簡(jiǎn)單的計(jì)算器。
iPhone手機(jī)調(diào)用科學(xué)計(jì)算器
第三步:之后我們只要旋轉(zhuǎn)手機(jī),讓手機(jī)由豎向轉(zhuǎn)為橫向,計(jì)算器就可以變?yōu)椤翱茖W(xué)計(jì)算器”的界面了,這時(shí)用戶就可以算那些復(fù)雜的數(shù)據(jù)了。
iPhone手機(jī)調(diào)用科學(xué)計(jì)算器
#import UIKit/UIKit.h
@interface LEViewController : UIViewController
{
double a;
double b;
double c;
UITextField *atextField;
UILabel *aLabel;
NSString *str;
NSMutableString *str1;
}
@end
#import "LEViewController.h"
@interface LEViewController ()
@end
@implementation LEViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
str1=[[NSMutableString alloc]init ];}
return self;
}
/**
*@控制器入口
*
*/
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view setBackgroundColor:[UIColor blueColor] ];
aLabel= [[UILabel alloc]initWithFrame:CGRectMake(100, 20, 80, 40)];
[aLabel setText:@" 計(jì)算器"];
[self.view addSubview:aLabel];
atextField =[[UITextField alloc]initWithFrame:CGRectMake(0, 60, 320, 50)];
[atextField setBorderStyle:UITextBorderStyleRoundedRect];
[self.view addSubview:atextField];
UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:CGRectMake(20, 380, 270, 60)];
[button setTitle:@"=" forState:UIControlStateNormal];
[button addTarget:self action:@selector(go) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
UIButton *button1=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button1 setFrame:CGRectMake(20, 110, 60, 60)];
[button1 setTitle:@"1" forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(one) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button1];
UIButton *button2=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button2 setFrame:CGRectMake(90, 110, 60, 60)];
[button2 setTitle:@"2" forState:UIControlStateNormal];
[button2 addTarget:self action:@selector(two) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button2];
UIButton *button3=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button3 setFrame:CGRectMake(160, 110, 60, 60)];
[button3 setTitle:@"3" forState:UIControlStateNormal];
[button3 addTarget:self action:@selector(three) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button3];
UIButton *button4=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button4 setFrame:CGRectMake(20, 170, 60, 60)];
[button4 setTitle:@"4" forState:UIControlStateNormal];
[button4 addTarget:self action:@selector(four) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button4];
UIButton *button5=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button5 setFrame:CGRectMake(90, 170, 60, 60)];
[button5 setTitle:@"5" forState:UIControlStateNormal];
[button5 addTarget:self action:@selector(five) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button5];
UIButton *button6=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button6 setFrame:CGRectMake(160, 170, 60, 60)];
[button6 setTitle:@"6" forState:UIControlStateNormal];
[button6 addTarget:self action:@selector(six) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button6];
UIButton *button7=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button7 setFrame:CGRectMake(20, 240, 60, 60)];
[button7 setTitle:@"7" forState:UIControlStateNormal];
[button7 addTarget:self action:@selector(seven) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button7];
UIButton *button8=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button8 setFrame:CGRectMake(90, 240, 60, 60)];
[button8 setTitle:@"8" forState:UIControlStateNormal];
[button8 addTarget:self action:@selector(eight) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button8];
UIButton *button9=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button9 setFrame:CGRectMake(160, 240, 60, 60)];
[button9 setTitle:@"9" forState:UIControlStateNormal];
[button9 addTarget:self action:@selector(nine) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button9];
UIButton *button10=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button10 setFrame:CGRectMake(20, 310, 60, 60)];
[button10 setTitle:@"0" forState:UIControlStateNormal];
[button10 addTarget:self action:@selector(zero) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button10];
UIButton *button11=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button11 setFrame:CGRectMake(90, 310, 60, 60)];
[button11 setTitle:@"." forState:UIControlStateNormal];
[button11 addTarget:self action:@selector(dian) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button11];
UIButton *button12=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button12 setFrame:CGRectMake(230, 240, 60, 60)];
[button12 setTitle:@"*" forState:UIControlStateNormal];
[button12 addTarget:self action:@selector(chen) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button12];
UIButton *button13=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button13 setFrame:CGRectMake(160, 310, 60, 60)];
[button13 setTitle:@"AC" forState:UIControlStateNormal];
[button13 addTarget:self action:@selector(ac) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button13];
UIButton *button14=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button14 setFrame:CGRectMake(230, 310, 60, 60)];
[button14 setTitle:@"/" forState:UIControlStateNormal];
[button14 addTarget:self action:@selector(chu) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button14];
UIButton *button15=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button15 setFrame:CGRectMake(230, 110, 60, 60)];
[button15 setTitle:@"+" forState:UIControlStateNormal];
[button15 addTarget:self action:@selector(add) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button15];
UIButton *button16=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button16 setFrame:CGRectMake(230, 170, 60, 60)];
[button16 setTitle:@"-" forState:UIControlStateNormal];
[button16 addTarget:self action:@selector(jian) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button16];
}
-(void)one
{
str =@"1";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];
}
-(void)two
{
str =@"2";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];
}
-(void)three
{
str =@"3";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];
}
-(void)four
{
str =@"4";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];}
-(void)five
{
str =@"5";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];}
-(void)six
{
str =@"6";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];}
-(void)seven
{
str =@"7";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];}
-(void)eight
{
str =@"8";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];}
-(void)nine
{
str =@"9";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];}
-(void)add
{
str =@"+";
[str1 appendString:str];
atextField.text=str1;
b='1';c=a;
a=[str1 doubleValue];
[str1 release];
str1=[[NSMutableString alloc] init];}
-(void)jian
{
str =@"-";
[str1 appendString:str];
atextField.text=str1;
b='2';c=a;
a=[str1 doubleValue];
[str1 release];
str1=[[NSMutableString alloc] init];}
-(void)chen
{
str =@"*";
[str1 appendString:str];
atextField.text=str1;
b='3';c=a;
a=[str1 doubleValue];
[str1 release];
str1=[[NSMutableString alloc] init];}
-(void)chu
{
str =@"/";
[str1 appendString:str];
atextField.text=str1;
b='4';c=a;
a=[str1 doubleValue];
[str1 release];
str1=[[NSMutableString alloc] init];}
-(void)dian
{
str =@".";
[str1 appendString:str];
atextField.text=str1;
a=[str1 doubleValue];}
-(void)ac
{
str =@"0";
atextField.text=@"0";}
-(void)zero
{
str =@"0";
[str1 appendString:str];
atextField.text=str1;}
-(void)go
{if (b=='1') {br/p atextField.text=[NSString stringWithFormat:@"%f",(a+c)];}
if (b=='2') {
atextField.text=[NSString stringWithFormat:@"%f",(c-a)];}
if (b=='3') {
atextField.text=[NSString stringWithFormat:@"%f",(a*c)];}
if (b=='4') {
atextField.text=[NSString stringWithFormat:@"%f",(a/c)];}
if (b=='5') {
atextField.text=[NSString stringWithFormat:@"0"];}
[str1 release];
str1=[[NSMutableString alloc] init];}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{return (interfaceOrientation == UIInterfaceOrientationPortrait);}
@end