WatchKit Control Overlay achieves a similar addsubview effect

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.