C# iOS Xamarin tableview
来源:互联网 发布:百合 知乎 编辑:程序博客网 时间:2024/06/16 19:24
Xamarin开发iOS
今天,偶然的发现C#能够开发iOS了。到网上查阅了一下资料,原来是Xamarin团队做的跨平台开发技术,最近被微软收购了,最重要的是已经和VS结合了,而且个人版本的开发环境已经不需要花钱了,想必大家一听到免费,大家都会比较感兴趣,哈哈,屌丝我也是其中一员呢。在mac系统上面安装xamarin是非常简单的,首先安装Xcode,因为要用到Xcode的一些东西(模拟器),然后到官网上面下载,按照教程安装就行,安装环境需要的一些插件,都会提醒我们下载的,傻瓜似的安装。
下面,我来给大家做一个小小的demo,在iOS开发中,tableview我们是用的非常多的。下面的例子就是用C#开发一个tableview,实现一级二级数据的现实。
下面的这个是数据源的class;
using System;using UIKit;using Foundation;using System.Collections.Generic;namespace Expland{public class MyTableViewSource:UITableViewSource{string cellReuseId="cellReuseId";List<string> firstTitle;//构造函数,传递参数public MyTableViewSource (List<string> firstTitle){this.firstTitle = firstTitle;}//每一行的内容public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath){UITableViewCell cell = tableView.DequeueReusableCell (cellReuseId);if (cell == null) {cell = new UITableViewCell (UITableViewCellStyle.Default, cellReuseId);}cell.TextLabel.Text = "123";return cell;}//每一个section的行数public override nint RowsInSection (UITableView tableview, nint section){return 1;}//section的个数public override nint NumberOfSections (UITableView tableView){return firstTitle.Count;}//section要现实的内容public override nfloat GetHeightForHeader (UITableView tableView, nint section){return 44f;}//section的高度public override UIView GetViewForHeader (UITableView tableView, nint section){UITableViewHeaderFooterView headerView = new UITableViewHeaderFooterView ();headerView.TextLabel.Text=firstTitle[(int) section];headerView.TextLabel.TextColor = UIColor.Black;return headerView;}}}
using System;using Foundation;using System.Collections.Generic;using UIKit;namespace Expland{public partial class ViewController : UIViewController{UITableView tableview;List<string> firstTitle;List<Data> secondTitile;public ViewController (IntPtr handle) : base (handle){}public override void ViewDidLoad (){base.ViewDidLoad ();firstTitle = new List<string> (){ "A", "B", "C", "D", "E", "F" };InitTableView ();InitNavigation ();//tableview的数据源this.tableview.Source = new MyTableViewSource (firstTitle);}//tableview初始化void InitTableView (){tableview = new UITableView (new CoreGraphics.CGRect (0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height));this.View.AddSubview(tableview);}//导航栏初始化void InitNavigation(){this.NavigationItem.Title = "首页";}public override void DidReceiveMemoryWarning (){base.DidReceiveMemoryWarning ();}}}
0 0
- C# iOS Xamarin tableview
- C# iOS Xamarin tableview 复用的使用
- Xamarin之TableView
- xamarin c#开发ios/android 应用
- xamarin c#开发ios/android 应用
- xamarin c#开发ios/android 应用
- C#苹果应用开发——第一讲初始Xamarin Xamarin ios 教程 Xamarin跨平台开发
- Xamarin ios 教程 Xamarin跨平台开发 C#苹果应用开发
- Xamarin 从原生IOS Native Library SDK创建Xamarin版本的C# SDK Bindings
- Xamarin Evolve 2013:竭尽全力让C#服务iOS与Android
- Xamarin体验:使用C#开发iOS/Android应用
- Xamarin Evolve 2013:竭尽全力让C#服务iOS与Android
- Xamarin体验:使用C#开发iOS/Android应用
- VS 2012 Xamarin 安卓 ios C#开发
- Xamarin体验:使用C#开发iOS/Android应用
- ios tableview
- iOS tableView
- TableView iOS
- 计算机组成原理(1)
- Activity的四种启动模式及其应用
- java类之间继承、实现、组合、聚合、关联、依赖
- js实现ajax
- 使用easyBCD引导启动ubuntu14.04
- C# iOS Xamarin tableview
- MYSQL导入导出.sql文件
- Python--网络爬虫之基础篇
- Spiral Matrix
- TextView显示Gif图片实现图文混排
- 最小费用流
- 智猪博弈论
- Open Judge 1664 Placing apples
- Myclipse项目更换svn路径