Trying to get button to spin in WatchKit

前端 未结 1 1178
别跟我提以往
别跟我提以往 2021-01-28 19:59

the code i\'m using works just fine in swift for iPhone apps but not in the WatchKit 7.0 beta. the outlets and actions are different. I\'m not sure what needs to change to make

相关标签:
1条回答
  • 2021-01-28 20:30

    You are limited to a subset of all the APIs available on iOS when developing for the watchOS.

    If you want to do basic animations try out a WKInterfacePicker and change images when the digital crown is moved.

    IBOutlet WKInterfacePicker *myPicker;
    
    - (void)willActivate {
        [super willActivate];
    
        WKPickerItem *item1 = [[WKPickerItem alloc] init];
        item1.contentImage = [WKImage imageWithImageName:@"Unknown.png"];
    
        WKPickerItem *item2 = [[WKPickerItem alloc] init];
        item2.contentImage = [WKImage imageWithImageName:@"Unknown-2.png"];
    
        [self.myPicker setItems:array];
    
    }
    

    When the value exceeds the array count start over from index 0.

    - (IBAction)myPickerAction:(NSInteger)value {
    
        if (value % 2 == 0) {
            [self.myPicker setSelectedItemIndex:-1];
        }
    
    }
    

    This will make the WKInterfacePicker change between your images when the digital crown is rotated.

    0 讨论(0)
提交回复
热议问题