2014-03-28 60 views
0

我正在開發使用parse.com作爲後端的應用程序,該應用程序正在完善免費卡,並且我可以顯示所有卡並單擊任何卡以具有完整視圖,以便客戶可以編寫文本並定製併發送給朋友。在parse.com中添加應用內購買

我的問題是如何將高級卡添加到應用程序,以便客戶需要購買之前,他可以使用它併發送給朋友。是否可以在同一視圖中同時顯示免費卡和優質卡,並在優質卡上添加標籤價格?

我使用Carousol來顯示所有的卡,這爲顯卡

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view 
{ 
    self.cardFileArray = [[NSMutableArray alloc] init]; 


    //create new view if no view is available for recycling 

     view = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 250.0f, 350.0f)] autorelease]; 


     PFQuery *query = [PFQuery queryWithClassName:WALL_OBJECT3]; 

     query.cachePolicy = kPFCachePolicyCacheOnly; 



     [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { 
      if (!error) { 

       cardFileArray = [[NSMutableArray alloc] initWithArray:objects]; 
       PFObject *object = [cardFileArray objectAtIndex:index]; 
       PFFile *file = [object objectForKey:KEY_IMAGE4]; 

       [file getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { 
        if (!error) { 

         ((UIImageView *)view).image = [UIImage imageWithData:data]; 


        } 
       }]; 
      } 
     }]; 



    } 

代碼而此時客戶選擇卡預覽和編輯代碼

-(void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index{ 


    PFObject *object = [cardFileArray objectAtIndex:index]; 
    PFFile *file = [object objectForKey:KEY_IMAGE5]; 
    NSString *tmpObject = [NSString stringWithFormat:@"%@",object.objectId]; 

    [HUD showUIBlockingIndicatorWithText:@"Loading Card"]; 

    [file getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { 
     if (!error) { 


      CardDetailsViewController*ptvc = [self.storyboard instantiateViewControllerWithIdentifier:@"cardsDetail"]; 

      [self.navigationController pushViewController:ptvc animated:YES]; 

      ptvc.ImageForDetail = [UIImage imageWithData:data]; 

      ptvc.imageString = tmpObject; 
      ptvc.title = title2; 

      [HUD hideUIBlockingIndicator]; 

     } 
    }]; 

} 

你能幫助我如何添加應用程序內購買到我的應用程序

謝謝

回答

0

是的,這是可能的。您需要保存卡的類型(免費/收費),或者簡單地將它的價格保存在您從查詢中獲取的數據中的代碼中。然後,根據它的狀態,可以在-viewForItemAtIndex方法中的圖像上應用標籤。

至於實施應用內購買,您應該閱讀它here

+0

謝謝,所以我應該在Parse查詢中添加價格關鍵字,並在價格關鍵字大於0時添加條件,然後申請購買並應用它。這樣對嗎? – sramadan

+0

正確!這應該工作。 – ZeMoon