Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > iOS ทำไมเวลา Search ข้อมูลเเสดงบน TableView ถึงไม่มีเครื่องหมายเพื่อลิ้งค์ไปหน้า Detail view



 

iOS ทำไมเวลา Search ข้อมูลเเสดงบน TableView ถึงไม่มีเครื่องหมายเพื่อลิ้งค์ไปหน้า Detail view

 



Topic : 112064



โพสกระทู้ ( 67 )
บทความ ( 0 )



สถานะออฟไลน์




ผมทำ Search ข้อมูลหน้าหลักMaster เพื่อลิ้งค์ไปหน้า Detail เเต่ตอนค้นหากลับไม่เเสดงสัญลักษณ์(Disclosure Indicator)ลิ้งไปหน้า Detail ต้องเเก้ไขตรงไหนครับ

รูป
err

code

Code (Objective-C)
//
//  CatalotTableViewController.m
//  AddaShoeApp
//
//  Created by Admin on 10/17/2557 BE.
//  Copyright (c) 2557 Admin. All rights reserved.
//

#import "CatalotTableViewController.h"
#import "DetailCatalogViewController.h"

@interface CatalotTableViewController ()
{
    NSMutableArray *filtered;
    NSMutableArray *myObject;
    NSDictionary *dict;
    
    NSString *prodcode;
    NSString *images;
}

@end

@implementation CatalotTableViewController
@synthesize tbv;
@synthesize searchBar;

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    prodcode = @"Prodcode";
    images = @"Images";
    
    myObject = [[NSMutableArray alloc]init];
    
    NSData *jsonData = [NSData dataWithContentsOfURL:
                        [NSURL URLWithString:@"http://10.32.1.151:81/sample_shoe/GetData.php"]];
    
    id jsonObjects = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];
    
    //values in foreach loop
    for (NSDictionary *dataDict in jsonObjects)
    {
        NSString *strProdCode = [dataDict objectForKey:@"prodcode"];
        NSString *strImages = [dataDict objectForKey:@"images"];
        
        dict = [NSDictionary dictionaryWithObjectsAndKeys:
                strProdCode,prodcode,
                strImages,images,
                nil];
        
        [myObject addObject:dict];
        
    }
    
    filtered = [[NSMutableArray alloc]initWithArray:myObject];
}

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    [filtered removeAllObjects]; //ให้ทำการลบข้อมูลทั้งหมดออกก่อน
    if (searchText.length == 0)  
    {
        [filtered addObjectsFromArray:myObject];
    }
    else
    {
       
        for (NSDictionary *tmpDict in myObject)
        {
            NSString *val = [tmpDict objectForKey:prodcode];
            
            NSRange r = [val rangeOfString:searchText options:NSCaseInsensitiveSearch];
            if (r.location != NSNotFound)
            {
              [filtered addObject:tmpDict];
            }
            
        }
        
    }
    
    [tbv reloadData]; //โหลด Data ใหม่ให้เป็นปัจจุบัน
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.tbv)
    {
        return  myObject.count;
    }
    else{
        return  filtered.count;
    }
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    NSDictionary *tmpDict;
    if (tableView == self.tbv)
    {
       tmpDict = [myObject objectAtIndex:indexPath.row];
    }
    else
    {
       tmpDict = [filtered objectAtIndex:indexPath.row];
    }
    
    NSURL *url = [NSURL URLWithString:[tmpDict objectForKey:images]];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *img = [[UIImage alloc]initWithData:data];
    
    cell.imageView.image = img;
    cell.textLabel.text = [tmpDict objectForKey:prodcode];

    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [searchBar resignFirstResponder];
}


- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
   if ([[segue identifier] isEqualToString:@"mnuSelect"])
   {
     
       NSIndexPath *indexPath = [self.tbv indexPathForSelectedRow];
       
       NSDictionary *tmpDict = [myObject objectAtIndex:indexPath.row];
       
       [[segue destinationViewController] setImageItem:[tmpDict objectForKey:images]];
       [[segue destinationViewController] setModelItem:[tmpDict objectForKey:prodcode]];
       
   }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end





Tag : Mobile, Ms SQL Server 2008, iOS, Mobile









ประวัติการแก้ไข
2014-10-20 20:31:01
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-10-20 20:29:05 By : junior_dev View : 1008 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (Objective-C)
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 


Code (Objective-C)
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;


ลองดูครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-10-22 09:41:45 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : iOS ทำไมเวลา Search ข้อมูลเเสดงบน TableView ถึงไม่มีเครื่องหมายเพื่อลิ้งค์ไปหน้า Detail view
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่