0

我正在 IOS 中进行 Instagram 集成。一切顺利。我正在获取用户的提要并在 tableview 和滚动视图中显示它们。这里允许用户刷新页面。虽然刷新方法没有得到调用它并且由于数组中的零个对象而崩溃。我使用以下代码调用该方法。

-(IBAction)loginAction:(id)sender
{
        AppDelegate* appDelegate_new = (AppDelegate*)[UIApplication sharedApplication].delegate;
      [appDelegate_new.instagram authorize:[NSArray arrayWithObjects:@"comments", @"likes", nil]];


      if ([appDelegate.instagram isSessionValid]) {

    //  NSLog(@"ViewDidLoad Session Valid");

          loginView.hidden=YES;
          crossButton.hidden=YES;
          settingsButton.hidden=NO;
          noticeView.hidden=YES;

          [self.view addSubview:feedsView];
         // [self.logOutView removeFromSuperview];
          self.feedsView.frame=CGRectMake(0, 0, 240, 300);
          NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self/feed", @"method", nil];
          [appDelegate.instagram requestWithParams:params
                                    delegate:self];
    } 
}

被调用的方法是这样的

      - (void)request:(IGRequest *)request didLoad:(id)result
      {

          [self performSelector:@selector(startspinner) withObject:nil afterDelay:0.1];
          self.data = (NSMutableArray *)[result objectForKey:@"data"];
        // NSLog(@"Data Count is %@",[self.data description]);
          createdArray=[[NSMutableArray alloc]init];

        //*****Here I am performing Json Parsing******//

      }

我在刷新时再次调用上述请求方法

    - (void)dropViewDidBeginRefreshing:(ODRefreshControl *)refreshControl
      {
            [createdArray removeAllObjects];

            NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self/feed", @"method", nil];
            [appDelegate.instagram requestWithParams:params
                                delegate:self];
            [self performSelector:@selector(refreshData) withObject:nil afterDelay:5.0];
      }

请告诉我哪里出错了。更正感谢。在此先感谢。

4

1 回答 1

0

试试看....

[NSTimer scheduledTimerWithTimeInterval:0.5f
                                 target:self
                               selector:@selector(showTime)
                               userInfo:NULL
                                repeats:YES];

- (void)showTime
{
    NSLog(@"Method called");
}

频繁使用 NSTimer 作为调用方法。
希望我有所帮助。

于 2013-05-02T05:34:13.377 回答