First, the Uiimageview initwithimage: Method
1. QuestionsSee someone discussing why this creates a uiimageview that will not be shown, the code is as follows:Uiimageview* ImageView = [[UiimageviewAlloc]init]; ImageView.Image= [UIImageImagenamed:@ "Icon.png"]; [Self.view addsubview:imageview]; The first eye to see this problem, intuitive to think that the view is no size, certainly cannot be displayed. Later found that the original use of the wrong should be the code as follows:
Uiimageview* ImageView = [[UiimageviewAlloc]Initwithimage:[UIImageImagenamed:@ "Icon.png"]; [Self.View addsubview: ImageView];
run the code manually, really, why do you use this phenomenon?
2. Analysis
a Uiimageview is created in two different ways, and the corresponding properties are output:1, with initwithimage: Initialize <UIImageView:0x7fa1ca8225d0; frame = (0 0; opaque = no; userinteractionenabled = no; layer = <calayer: 0x7fa1c8ca2060>>2. Initialize with init<UIImageView:0x7f9b449aa030; frame = (0 0; 0 0); opaque = no; userinteractionenabled = no; layer = <calayer:0x 7f9b4490cfa0>>
3. Conclusion
initwithimage: Initialization automatically sets the size of the view, and Init does not set the view size. ii. Local Declaration of ' XXX ' hides instance variable When you write code, you see a code warning:looked for a long time, found that the original was accidentally re-declared a variable with the same name as the member variable, the code is as follows: Summary: So now understand the above warning message is that this variable is overwritten.
ios-share two small questions