iOS中的提醒用户及多场景(201549)

来源:互联网 发布:燕十八mysql教程 编辑:程序博客网 时间:2024/06/07 14:53
VC中MessageBox(…),我想大家应该不会陌生,在iOS中也有类似的功能,主要的是指UIAlertView、UIActionSheet、系统声音服务。直接上代码片段。

1.UIAlertView *alert;
   alert=[[UIAlertView alloc] initWithTitle:@"title" message:@"Message" delegate:self cancelButtonTitle:@“OK”
   otherButtonTitle:nil];
   alert.alertViewStyle=UIAlertViewStylePlainTextInput; 

   [alert show];

alertViewStyle:四种样式

  • UIAlertViewStyleDefault
  • UIAlertViewStyleTextInput
  • UIAlertViewStyleInput
  • UIAlertViewStlyleLoginAndPasswordInput(文本框和密码文本文本框)


2.UIActionSheet:
    UIActionSheet *actionSheet;
    actionSheet=[[UIActionSheet alloc]      initWithTitle:@"Available" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"Destroy" otherButtonTitles:@"Negotitate",@"Compromise", nil];
    actionSheet.actionSheetStyle=UIActionSheetStyleDefault;
    [actionSheet showFromRect:[(UIButton *)sender frame] inView:self.view animated:YES];

3.系统声音
    SystemSoundID soundID;
    NSString *soundFile=[[NSBundle mainBundle] pathForResource:@"XXX" ofType:@"wav"];
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundFile], &soundID);
    AudioServicesPlaySystemSound(soundID);

(注意:bridge前面是两个”_”)

(PS:上面列出了最最基本的东西)


4.场景是由一个视图控制器和一个视图定义的。

出口:Exit,出口可用于切换到以前的场景。

切换:切换是场景间的过渡,常使用视觉过渡效果。

关系:类似与切换,用于某些类型的视图控制器,如选项卡栏的控制器。

故事板:包含项目中的场景、切换和关系的文件。


5.切换视图:storyboardSegu设置

transiton设置:

CoverVertical:新场景从下向上移动,逐渐覆盖旧场景

Flip Horizontal:视图水平翻转,以显示背面的新场景(个人比较喜欢)

Cross Dissolve:旧场景淡出,新场景淡入

Partial Curl:旧场景像书页一样翻开,显示下面的新场景


6.main.storyBoard中的Exit按钮可以实现回退的功能,可以尝试连线,在多个ViewController之间实现回退功能。

待实践:

canPerformUnwindSegueAction:fromViewController:withSender

动态的确定视图层次结构中的视图能否成为回退切换的目标,通过覆盖这个方法,可以让视图控制器根据发起回退的视图控制器决定是否接受回退请求,进而返回Yes或No。如果返回No,发起回退的视图将继续查找。


7.设置storyBoard ID实现跳转

    UIStoryboard *mainStoryboard=[UIStoryboardstoryboardWithName:@"Main"      bundle:nil];

    EditorViewController *editerVC=[mainStoryboardinstantiateViewControllerWithIdentifier:@"<#storyBoard ID#>"];

    [selfpresentViewController:editerVC animated:YEScompletion:nil];


8.在场景中传递数据:

待实践。

prepareForSegue:sender






0 0
原创粉丝点击