Recently playing watch, by studying the layout of watch, it was found that the Interfacecontroller native layout is only horizontal and vertical, and the controls cannot overlap, and you cannot add child controls as Addsubview.
But I see the following interface in NetEase news:
Very curious how his title is stacked on the picture, think for a long time to think of the following scenarios:
dynamically generate the corresponding picture, directly processing it out.
This is what I realized after:
You can see that the title has been stacked on top of the picture.
To process the specific method steps are:
1. Appdelegate of the app (the app in the phone)
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply
method, create the ImageView, and in the appropriate layout, add after the corresponding view, the use of the function, the view as a picture sent to watch. So this picture looks like it's adding a child control.
2. In the watch side of the Interfacecontroller, get the corresponding pictures and other information, do the watch standard layout.
[WKInterfaceController openParentApplication:userInfo reply:^(NSDictionaryNSError *error){ //主应用处理完后的回调,返回extension所需的数据 dispatch_async(dispatch_get_main_queue(), ^{ NSString *words = [replyInfo objectForKey:@"words"]; NSData *data = [replyInfo objectForKey:@"image"]; [_image setImageData:data]; [_label setText:words]; }); }];
Other programs, perhaps directly on the watch side can also be processed, but the performance of my personal preference in the mobile phone end of the submission of a better, of course, we also have to consider the watch and mobile data transmission speed and power consumption problems, as small as possible, picture compression some.
Write a relatively simple, clear method to achieve, concrete can practice play a play, welcome everyone message exchange.
Copyright NOTICE: This article is for bloggers original article, welcome reprint but please keep the article source. http://blog.csdn.net/u010124617
WatchKit Control Overlay achieves a similar addsubview effect