小编Ant*_*ony的帖子

将数据传递回上一个viewcontroller

我正在尝试将数据传递回以前的viewController.

有谁知道如何将数据从ViewController B传递回ViewController A?所以我想要一个字符串'从'BIDAddTypeOfDealViewController转到BIDDCCreateViewController.用户编辑了viewController B,我想在ViewController A中返回已编辑的数据然后我使用它.

我正在使用此答案的"传递数据"部分.我的不同之处:第3点和第6点只是在弹出视图时提及,所以我将该代码放在viewWillDisappear中.我认为这是正确的吗?同样在Point 6,我没有使用nib进行初始化,因为它已经过时了.我正在使用故事板.而且我没有添加最后一行,因为我不相信我会推动它.按我的故事板上的按钮已经让我前进了.

我认为问题可能出现在BIDDCCreateViewController中,我有方法,但我无法运行它.要运行一个方法,它应该[自我方法].我无法做到这一点.那就是我猜的.

它编译并运行良好,没有任何记录,所以我不知道它是否有效.

更新:我无法获得'sendDataToA'方法来执行.

#import <UIKit/UIKit.h>
#import "BIDAddTypeOfDealViewController.h"

 @interface BIDDCCreateViewController : UIViewController
 @property (strong, nonatomic) NSString *placeId;
- (IBAction)gotoBViewController:(id)sender;
@end


#import "BIDDCCreateViewController.h"
#import "BIDAddTypeOfDealViewController.h"

@implementation BIDDCCreateViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSLog(@"SUCCESSFULLY PASSED PLACE ID: %@", self.placeId);
}

-(void)sendDataToA:(NSString *)myStringData
{

    NSLog(@"Inside sendDataToA");
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your string Data Showing" message:myStringData delegate:self cancelButtonTitle:@"Ok " otherButtonTitles:nil];
    [alert show];
}

- (IBAction)gotoBViewController:(id)sender …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiviewcontroller ios

53
推荐指数
3
解决办法
6万
查看次数

当异步调用存在时,从cellForRowAtIndexPath返回单元格

在为tableview返回单元格时,我在视图控制器中遇到问题.我正在使用Parse后端来获取文件.那里有2个异步调用.据我所知,此外的代码将首先执行,依赖于结果的代码应该在块中.

简而言之,我的代码如下:我有一个模型对象的模型数组.我使用该对象设置标签和屏幕上的图像.地点图像存储在解析后端中,在我的附件中它是左上角的图像.我试图检索它并在左上角的图像中显示它.

在每个NSLog旁边,我有它正在构建的模型对象的代码,即'Di2zPyCmn8'.那是一个模型对象id.

从我的日志记录中,您可以看到单元格在一切完成之前返回.这是有意义的,因为块是异步的.

任何人都可以提供一些帮助,以便我可以正确构建tableviews吗?

不正当行为是指我在Parse中的后端没有图像作为对象.tableview单元格图像(左上角)应为空白.有时候,可以在那里找到来自其他后端对象的随机图像.

我相信这与细胞的流动和早期恢复有关.

当我在后端有图像时,该图像按预期显示在地点图像视图(左上角)中.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{


    static NSString *CellIdentifier = @"Cell";

    BIDActiveDealCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[BIDActiveDealCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    //get model object from array and use it's properties to populate the fields from CustomCell.h
    if ([self.activeDealModelArray count] == 0) {
        cell.descriptionLabel.text = @"Array count is 0";

    }else{
BIDActiveDealModel *dealActiveModel = [[BIDActiveDealModel alloc]init];
        dealActiveModel = self.activeDealModelArray[indexPath.row];

    NSLog(@"cellforRow - start of else : %@", dealActiveModel.placeObjectId); …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

0
推荐指数
1
解决办法
1028
查看次数

if语句的多个条件

我正在尝试使用子句构建一些"if语句".基本上,如果评级在0到1之间,我想显示一张图片,如果它在1和2之间,我会显示另一张图片等.

不幸的是,我从编译器中得到错误'预期表达式'.有谁知道我做错了什么?

提前致谢.

if (self.rating => 0 && self.rating < 1) {//rating between 0 and 1
        self.finalRatingImageView.image = [UIImage imageNamed:@"ratingSS1.png"];
    }else if (self.rating >= 1 && self.rating < 2){
        self.finalRatingImageView.image = [UIImage imageNamed:@"ratingSS2.png"];
    }else if (self.rating >= 2 && self.rating <= 3){
        self.finalRatingImageView.image = [UIImage imageNamed:@"ratingUltimate.png"];
    }
Run Code Online (Sandbox Code Playgroud)

int if-statement objective-c

0
推荐指数
1
解决办法
92
查看次数