2当然是记录第二章的内容了,
今天应为工作需要,把uilabel的想过内容看了,在此记录
2.1UIAlertView 看完了,之前
typedef enum {
UIAlertViewStyleDefault = 0,UIAlertViewStyleSecureTextInput,UIAlertViewStylePlainTextInput,UIAlertViewStyleLoginAndPasswordInput
} UIAlertViewStyle;
2.2继续,UISwitch
2.3 继续 UIPickerView,虽然功能也会实现,但是每当看到
NSInteger result = 0;
if ([pickerView isEqual:self.myPicker]){
result = 10;}
return result;
1.if ([pickerView isEqual:self.myPicker]){ 没有这个判断
2.NSInteger result = 0; return result; 不知道这个返回0会有什么效果,特别是在设置高度等参数的时候。
2.4继续UIDatePicker
UIDatePickerModeCountDownTimer
搞不懂,这个是干嘛用的,理解的是按照沙漏一样,会有一个倒计时,程序跑起来,也没有倒计时的效果。
2.5 困死了。
2.6 继续 UISegmentedControl
addTarget:action:forControlEvents: 这个方法,还真是万能的
CGRect segmentedFrame = self.mySegmentedControl.frame;
segmentedFrame.size.height = 64.0f;
segmentedFrame.size.width = 300.0f;
self.mySegmentedControl.frame = segmentedFrame;
原来是这么设置的啊,之前我都没有加最后一句,难怪没有生效。
2.7UIViewController 继续
还是有收获的
we would have to load our view controllerfromthat.xibfile by passingthe.xibfile's full name to theinitWithNibNameparameter of theinitWithNibName:bundle:method of the view controller
2.8 继续UINavigationController
看完了,但是有点不踏实,回去实践一下,话说,这些例子,是不是都是没有拖控件,全部都是代码生产的。不知道这个title是怎么出来的。先撤。这个目前为止还没有试啊。
后续补充:
-
- (void) pushSecondController{
SecondViewController *secondController = [[SecondViewController alloc]initWithNibName:nilbundle:NULL];
[self.navigationController pushViewController:secondControlleranimated:YES];
}
[self.navigationController popViewControllerAnimated:YES];
这一节主要是传授这两个方法。刚刚发现后续都是关于navigationController的。估计看完也就会用了,哦也
2.9 主要讲可以可控制currentControllers,控制页面的展现
-
- (void) goBack{
/* Get the current array of View Controllers */
NSArray *currentControllers = self.navigationController.viewControllers;/* Create a mutable array out of this array */
NSMutableArray *newControllers = [NSMutableArrayarrayWithArray:currentControllers];
/* Remove the last object from the array */
[newControllers removeLastObject];
/* Assign this array to the Navigation Controller */
self.navigationController.viewControllers = newControllers}
2.10 主要将可以通过一个UIView 放到 self.navigationController上,代码如下
- (void)viewDidLoad{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
/* Create an Image View to replace the Title View */UIImageView *imageView =
[[UIImageView alloc]
initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 40.0f)];
imageView.contentMode = UIViewContentModeScaleAspectFit;
/* Load an image. Be careful, this image will be cached */UIImage *image = [UIImage imageNamed:@"FullSizeLogo.png"];
/* Set the image of the Image View */[imageView setImage:image];
/* Set the Title View */self.navigationItem.titleView = imageView;
}
2.11 看到这里了。先把代码给过了一遍,嗯,因为项目中navigationController用的少,所以不是那么熟,不过用法跟toolbar也差不多,明天细看文章吧。
看完了,主要是几个基本的用法,在这里列一下,
-
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStylePlain target:selfaction:@selector(performAdd:)];
还有系统的样式
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAddtarget:self
action:@selector(performAdd:)];
传进去一个view,这样就能展示万物了
self.navigationItem.rightBarButtonItem =
-
[[UIBarButtonItem alloc] initWithCustomView:simpleSwitch];
[self.navigationItem setRightBarButtonItem:rightBarButtonanimated:YES];
-
Presenting Multiple View Controllers withUITabBarController
看这个title就明白了,这个控件是用来干嘛的
switch from one section of your app toanother,
需要注意的是:When a tab bar loads up, it only loads the view of the first view controllerin its items. All other view controllers will be initialized but their viewswon't be loaded. This means, any code that you have written in theviewDidLoadof the second view controller willnotget executed untilafter the user taps on the second tab bar item for the first time. So if youassign a title to the second view controller in itsviewDidLoadand runyour app, you will realize that the title in the tab bar item is still empty.
2.13 对这个有了新的理解
self.title = @"Second"; 在uitabBar 里面和navigation bar 里面都会显示这个内容。但是这个是uiviewController里面的一个属性,修行不够,望解惑。
2.14 UITextField 继续,之前以为这个跟button一样简单,谁知道还有这么些delegate。 看完了
2.15 UITextView继续
2.18 看完了 UISrollView
2.22 UIPopoverController,在这里看到一直疑惑的,retain cycle 状态真差。
明白了,为什么在
PopoverContentViewController里面也要有一个
/* We shouldn't define this as strong. That will create a retain cycle
between the popover controller and the content view controller since the
popover controller retains the content view controller and the view controller will
retain the popover controller */
@property (nonatomic, weak) UIPopoverController *popoverController;
However, this view controller will need to have reference to the popover controller in order to dismiss the popover when the user taps on any of thebuttons. For this, we need to define a property in our content view controller to referto the popover:
不明白的地方果然是重点啊,下面还有解惑的
The popover controller sets a reference to itself in the content view con-troller after its initialization. This is very important. A popover control-lercannotbe initialized without a content view controller. Once thepopover is initialized with a content view controller, you can go aheadand change the content view controller in the popover controller, butnot during the initialization.
看完了,这个例子基本的用法应该就是这样子,还有一个属性 contentSizeForViewInPopover
和这个方法presentPopoverFromBarButtonItem:permittedArrowDirections:animated:method
看到最后也没有看到,有介绍哪个方法可以让用户点别的地方,不隐藏的的方法啊。?
retain cycle 应该是
content.popoverController = self.popoverController;
由这句话引起的
2.24 不知怎么回事,看到这里了。Keyboard Notifications
还是看到一些之前不知道的东西,pad 的键盘可以分开的,split分成两半。
会有这么一些消息
UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
其中有两个是比较特殊的。
only the UIKeyboardWillShowNotificationand theUIKeyboardWillHideNotificationnotifications carry a user-info dictionary with them with validkeys and values in those dictionaries.
keysUIKeyboardAnimationCurveUserInfoKey 表明是hide or display
UIKeyboardAnimationDurationUserInfoKey 时长 重点在duration
UIKeyboardFrameBeginUserInfoKey frame 是一个CGRect
UIKeyboardFrameEndUserInfoKey 一样,不过这个是end
介绍了基本的知识之后,上了个例子,大意是,弹出的键盘,把tableview 给挡住了。
viewDidLoad 开始监听
viewDidUnload 结束监听
接下来是实现,监听到这一消息之后的具体实现方法。
代码还挺长,我擦,怎么这么复杂。
NSDictionary *userInfo = [paramNotification userInfo];
NSValue *animationCurveObject =
[userInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey];
NSValue *animationDurationObject =
[userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey];
NSValue *keyboardEndRectObject =
[userInfo valueForKey:UIKeyboardFrameEndUserInfoKey];
NSUInteger animationCurve = 0;
double animationDuration = 0.0f;
CGRect keyboardEndRect = CGRectMake(0, 0, 0, 0);
[animationCurveObject getValue:&animationCurve];[animationDurationObject getValue:&animationDuration];[keyboardEndRectObject getValue:&keyboardEndRect];
这个&的小伎俩,我还真不会。
果然比想象中的要复杂,那个因为坐标系的问题,不同的方向还不一样。
我给加了段代码
NSLog(@"keyboardEndRectObject:%@ ;%f ",keyboardEndRectObject,bottomInset);
2012-10-26 16:58:33.832 Listening and Reacting to Keyboard Notifications[13718:f803] keyboardEndRectObject:NSRect: {{0, 228}, {320, 252}} ;252.000000
2012-10-26 16:58:45.521 Listening and Reacting to Keyboard Notifications[13718:f803] keyboardEndRectObject:NSRect: {{0, 0}, {198, 480}} ;480.000000
发现,bottomInset都是正确的,呵呵,所以不转换坐标系倒也是无妨。over,回头补补吧,看看还有没有别的控件