내 TableView 용 맞춤 TableCell을 만들었습니다. 사용자 정의 셀에는 Button
이 있습니다. 그래서 Button이 click.and 일 때 새로운 ViewController를 열고 싶습니다. 그래서 새로운 ViewController를 열기 위해 Custom TableCell에서 이벤트를 만드는 법.맞춤 TableCell 버튼 iOS의 새 ViewController (Xamarin)
나는 이런 식으로 만들고있다.이 올바른 방법인가요?
내 CustomCell :
public partial class CaseHistotyTableCell : UITableViewCell
{
public static readonly NSString Key = new NSString("CaseHistotyTableCell");
public static readonly UINib Nib;
static CaseHistotyTableCell()
{
Nib = UINib.FromName("CaseHistotyTableCell", NSBundle.MainBundle);
}
protected CaseHistotyTableCell(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
public static CaseHistotyTableCell Create()
{
return (CaseHistotyTableCell)Nib.Instantiate(null, null)[0];
}
internal void BindData(string hospitalLabel, string addressLabel, string drLabel, string patientLabel)
{
this.lbl_hospitalName.Text = hospitalLabel;
this.lbl_address.Text = addressLabel;
this.lbl_drName.Text = drLabel;
this.lbl_patientName.Text = patientLabel;
this.lbl_address.TextColor = UIColor.Clear.FromHexString("#000000", 0.54f);
this.lbl_patientName.TextColor = UIColor.Clear.FromHexString("#000000", 0.54f);
this.lbl_hospitalName.TextColor = UIColor.Clear.FromHexString("#000000", 0.87f);
this.lbl_drName.TextColor = UIColor.Clear.FromHexString("#000000", 0.87f);
this.btn_createAppointment.SetTitleColor(UIColor.Clear.FromHexString("#0072BA",1.0f), UIControlState.Normal);
this.btn_viewDetail.SetTitleColor(UIColor.Clear.FromHexString("#0072BA", 1.0f), UIControlState.Normal);
this.btn_viewDetail.TouchUpInside += (sender, e) =>
{
};
}
public override CGRect Frame
{
get
{
return base.Frame;
}
set
{
value.Y += 4;
value.Height -= 2 * 4;
base.Frame = value;
}
}
}
sourceClass를 :
public class CaseHistorySourceClass : UITableViewSource
{
private List<CaseSearchItem> caseSearchItems;
public CaseSearchItem caseSearchItem;
public CaseHistorySourceClass(List<CaseSearchItem> caseSearchItems)
{
this.caseSearchItems = caseSearchItems;
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
CaseHistoryTableCell cell = tableView.DequeueReusableCell(CaseHistoryTableCell.Key) as CaseHistoryTableCell ?? CaseHistoryTableCell.Create();
var item = caseSearchItems[indexPath.Row];
cell.BindData(item.Organization, item.Address, item.Doctor, item.UserName);
cell.Layer.MasksToBounds = false;
cell.Layer.CornerRadius = 10.0f;
cell.BackgroundColor = UIColor.White;
return cell;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
return caseSearchItems.Count;
}
}
내가 iOS 및 자 마린 새로운 오전. 어떤 도움을 주셔서 감사합니다.
사용자 정의 셀에 대해 u는 'TableCell' 권한을 렌더링하고 있습니다. 클릭 할 때 ur 테이블 셀에서'button clicked '메소드를 호출해야한다고 가정합니다. 중단 점을 두어 클릭하면보기를 호출해야합니다. that thats extends TabbleCell – Smit