Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UILabel未更新与IBOutlet的连接_Iphone_Objective C_Ios_Ipad_Cocoa - Fatal编程技术网

Iphone UILabel未更新与IBOutlet的连接

Iphone UILabel未更新与IBOutlet的连接,iphone,objective-c,ios,ipad,cocoa,Iphone,Objective C,Ios,Ipad,Cocoa,我正在尝试更新IBOutlet的UILabel,但是由于某些原因,内容没有得到更新。最初,内容是从模型加载的,该模型以异步方式执行jsonResponse。但是,我已经设置了一个委托,一旦内容存在,就可以更新我调用setNeedsDisplay的布局 这里的任何帮助都将不胜感激 谢谢 代码如下: @interface pd () @property (nonatomic,retain) NSDictionary *pD; @property (nonatomic, retain) pd_mod

我正在尝试更新IBOutlet的UILabel,但是由于某些原因,内容没有得到更新。最初,内容是从模型加载的,该模型以异步方式执行jsonResponse。但是,我已经设置了一个委托,一旦内容存在,就可以更新我调用setNeedsDisplay的布局

这里的任何帮助都将不胜感激

谢谢

代码如下:

@interface pd ()

@property (nonatomic,retain) NSDictionary *pD;
@property (nonatomic, retain) pd_model *pdModel;

@end

@implementation pd

@synthesize pD = _pD, pdModel;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil :(NSDictionary*)pD {

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {
        // Custom initialization
        self.productDetails = [[NSDictionary alloc] initWithDictionary:pD];
        self.pdModel = [[ProductDetails_Model alloc] init:pD];
        self.pdModel.delegate = self;
        NSLog(@"%@",[self.pD description]);
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    [scrollView setBackgroundColor:[UIColor clearColor]];
    [self.view addSubview:scrollView];
    scrollView.showsHorizontalScrollIndicator = YES;
    scrollView.scrollEnabled = YES;

    // Do any additional setup after loading the view from its nib.

    productRecCarousel = [[iCarousel alloc] initWithFrame:CGRectMake(0.0f, scrollView.contentSize.height, 320.0f, 100.0)];
    productRecCarousel.delegate = self;

    [scrollView addSubview:productRecCarousel];

    [self addProductDescription];
    NSLog(@"%@",[self.pdModel responseCode]);
    [soldBy setText:[self.pdModel responseCode]];
    //[soldBy setText:@"1"];

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark
#pragma mark CarouselDelegate methods
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel {

    return 1;
}

- (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel {

    return 1;
}

- (UIView*)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view {

    return [[UIView alloc] init];
}

- (CGFloat)carouselItemWidth:(iCarousel *)carousel {
    //usually this should be slightly wider than the item views
    return 150;
}

- (CATransform3D)carousel:(iCarousel *)_carousel transformForItemView:(UIView *)view withOffset:(CGFloat)offset {
    //implement 'flip3D' style carousel

    //set opacity based on distance from camera
    view.alpha = 1.0 - fminf(fmaxf(offset, 0.0), 1.0);

    //do 3d transform
    CATransform3D transform = CATransform3DIdentity;
    transform.m34 = _carousel.perspective;
    transform = CATransform3DRotate(transform, M_PI / 8.0, 0, 1.0, 0);
    return CATransform3DTranslate(transform, 0.0, 0.0, offset * _carousel.itemWidth);
}

- (void)addProductDescription {

    NSLog(@"%f",addProductDetails.frame.size.height);
    addProductDetails.frame = CGRectMake(0.0f, productRecCarousel.frame.size.height, addProductDetails.frame.size.width, addProductDetails.frame.size.height);
    [scrollView addSubview:addProductDetails];


}

- (void)updateTheLayout {

    //[self.view setNeedsDisplay];
   //This is where I get the delegate called once the model is being updated. I tried scrollView and self.view setNeedsDisplay and setNeedsLayout but the IBoutlet never gets updated which is in "ViewDidLoad as assigned as" : [soldBy setText:[self.pdModel responseCode]];

}

谢谢。

您必须致电
[soldBy setText:[self.pdModel responseCode]在回调中,而不是在
viewDidLoad
方法中。

您必须调用
[soldBy setText:[self.pdModel responseCode]
在回调中,而不是在
viewDidLoad
方法中。

因此您只需调用
[soldBy setText:[self.pdModel responseCode]
更新布局
而不是从
视图加载
,因为它还没有准备好。请确保从主线程更新UI元素。

因此您只需调用
[soldBy setText:[self.pdModel responseCode]
更新布局
而不是从
视图加载
,因为它还没有准备好。请确保从主线程更新UI元素。

请发布一些代码,以便我们可以看到您正在做什么…@JShapiro,已经添加了代码。如果你在那里看到任何东西,请发表评论。谢谢。请发布一些代码,让我们看看你在做什么…@JShapiro,已经添加了代码。如果你在那里看到任何东西,请发表评论。谢谢。我只能答对一个,但你也答对了。谢谢@Ezekiyeah,我迟到了1分钟=)我只能回答一个正确的答案,但你也得到了正确的答案。谢谢@Ezekiyeah,我迟到了1分钟=)