当前位置: 首页>>代码示例>>C#>>正文


C# UITableView.InsertRows方法代码示例

本文整理汇总了C#中UITableView.InsertRows方法的典型用法代码示例。如果您正苦于以下问题:C# UITableView.InsertRows方法的具体用法?C# UITableView.InsertRows怎么用?C# UITableView.InsertRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UITableView的用法示例。


在下文中一共展示了UITableView.InsertRows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommitEditingStyle

        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, MonoTouch.Foundation.NSIndexPath indexPath)
        {
            switch (editingStyle) {
            case UITableViewCellEditingStyle.Delete:
                // remove the item from the underlying data source
                this.RaiseTaskDeleted(indexPath.Row);
                tableItems.RemoveAt(indexPath.Row);
                // delete the row from the table
                tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);

                break;

            case UITableViewCellEditingStyle.Insert:
                //---- create a new item and add it to our underlying data

                Item obj = new Item();
                obj.Name = "Inserted";
                obj.Description ="Placeholder";
            //				obj.imageFileName = "second.png";

                tableItems.Insert (indexPath.Row, obj);

                //---- insert a new row in the table
                tableView.InsertRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                break;

            case UITableViewCellEditingStyle.None:
                Console.WriteLine ("CommitEditingStyle:None called");
                break;
            }
        }
开发者ID:KuroiAme,项目名称:Indexer,代码行数:31,代码来源:TableSourceItems.cs

示例2: expandItemAtIndex

		void expandItemAtIndex(UITableView tableView, int index)
		{
			int insertPos = index + 1;
			key = false;

			tableView.InsertRows(new[] {NSIndexPath.FromRowSection(insertPos++, 0)}, UITableViewRowAnimation.Fade);

		}
开发者ID:tienbui123,项目名称:Mobile-VS2,代码行数:8,代码来源:LichHocTSource.cs

示例3: TasksTableViewSource

 public TasksTableViewSource(UITableView view, ObservableCollection<TodoItem> todos)
 {
     this.todos = todos;
     todos.CollectionChanged += (object sender, NotifyCollectionChangedEventArgs e) => {
         if (e.NewItems != null) {
             var newPaths = e.NewItems.OfType<TodoItem> ().Select (ni => NSIndexPath.FromRowSection (todos.Count - 1, 0))
                 .ToArray ();
             view.InsertRows (newPaths, UITableViewRowAnimation.Top);
         }
     };
 }
开发者ID:vproman,项目名称:TIG-CrossPlatformMobile-vproman,代码行数:11,代码来源:TasksTableViewSource.cs

示例4: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			table = new UITableView(View.Bounds); // defaults to Plain style
			table.AutoresizingMask = UIViewAutoresizing.All;
			List<TableItem> tableItems = new List<TableItem>();
			
			// credit for images and content
			// http://en.wikipedia.org/wiki/List_of_culinary_vegetables
			tableItems.Add (new TableItem("Vegetables") { SubHeading="65 items", ImageName="Vegetables.jpg"});
			tableItems.Add (new TableItem("Fruits") { SubHeading="17 items", ImageName="Fruits.jpg"});
			tableItems.Add (new TableItem("Flower Buds") { SubHeading="5 items", ImageName="Flower Buds.jpg"});
			tableItems.Add (new TableItem("Legumes") { SubHeading="33 items", ImageName="Legumes.jpg"});
			tableItems.Add (new TableItem("Bulbs") { SubHeading="18 items", ImageName="Bulbs.jpg"});
			tableItems.Add (new TableItem("Tubers") { SubHeading="43 items", ImageName="Tubers.jpg"});
			tableSource = new TableSource(tableItems, this);
			table.Source = tableSource;

			// To replace the standard edit button with a "Hi" button, uncomment out
			// these lines
			 tableDelegate = new TableDelegate ();
			 table.Delegate = tableDelegate;

			
			@add = new UIBarButtonItem(UIBarButtonSystemItem.Add, (s,e)=>{
				tableItems.Insert (0, new TableItem ("(inserted)") { SubHeading="0 items"}); // default new row
				table.InsertRows (new NSIndexPath[] { NSIndexPath.FromRowSection(0,0) }, UITableViewRowAnimation.Fade);
			});

			done = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s,e)=>{
				table.SetEditing (false, true);
				NavigationItem.LeftBarButtonItem = @add;
				NavigationItem.RightBarButtonItem = edit;
			});

			edit = new UIBarButtonItem(UIBarButtonSystemItem.Edit, (s,e)=>{
				if (table.Editing)
					table.SetEditing (false, true); // if we've half-swiped a row

				table.SetEditing (true, true);
				NavigationItem.LeftBarButtonItem = null;
				NavigationItem.RightBarButtonItem = done;
				
			});

			NavigationItem.RightBarButtonItem = edit;
			NavigationItem.LeftBarButtonItem = @add;


			
			Add (table);
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:52,代码来源:HomeScreen.cs

示例5: TasksTableViewSource

        public TasksTableViewSource(UITableView tableView, TaskManager taskManager)
        {
            _taskManager = taskManager;
            _taskManager.TodoItems.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => {
            //				if (e.OldItems != null)
            //				{
            //					NSIndexPath[] oldPaths = e.OldItems.OfType<TodoItem>().Select(oi => NSIndexPath.FromRowSection(tasks.IndexOf(oi), 0)).ToArray();
            //					tableView.DeleteRows(oldPaths, UITableViewRowAnimation.Top);
            //				}

                if (e.NewItems != null)
                {
                    var newPaths = e.NewItems.OfType<TodoItem>().Select(ni => NSIndexPath.FromRowSection(_taskManager.TodoItems.Count - 1, 0)).ToArray();
                    tableView.InsertRows(newPaths, UITableViewRowAnimation.Top);
                }
            };
        }
开发者ID:phamthangnd,项目名称:TIG-CrossPlatformMobile,代码行数:17,代码来源:TasksTableViewSource.cs

示例6: CommitEditingStyle

        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
        {
            switch (editingStyle) {
                case UITableViewCellEditingStyle.Delete:
                    // remove the item from the underlying data source
                    tableItems.RemoveAt(indexPath.Row);
                    // delete the row from the table
                    tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                    break;

                case UITableViewCellEditingStyle.Insert:
                    //---- create a new item and add it to our underlying data
                    tableItems.Insert (indexPath.Row, new TableItem ("(inserted)"));
                    //---- insert a new row in the table
                    tableView.InsertRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                    break;

                case UITableViewCellEditingStyle.None:
                    Console.WriteLine ("CommitEditingStyle:None called");
                    break;
            }
        }
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:22,代码来源:TableSource.cs

示例7: CommitEditingStyle

        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, MonoTouch.Foundation.NSIndexPath indexPath)
        {
            switch (editingStyle) {
                case UITableViewCellEditingStyle.Delete:
                    // remove the item from the underlying data source
                    tableItems.RemoveAt(indexPath.Row);
                    // delete the row from the table
                    tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);

                    var path = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);

                    DirectoryInfo dr = new DirectoryInfo(path);
                    FileInfo [] f  =  new FileInfo [10];

                    f = dr.GetFiles();

                    foreach (var file in f) {

                        File.Delete(file.FullName);

                    }

                    break;

                case UITableViewCellEditingStyle.Insert:
                    //---- create a new item and add it to our underlying data
                    tableItems.Insert (indexPath.Row, new TableItem ("(inserted)"));
                    //---- insert a new row in the table
                    tableView.InsertRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                    break;

                case UITableViewCellEditingStyle.None:
                    Console.WriteLine ("CommitEditingStyle:None called");
                    break;
            }
        }
开发者ID:satendra4u,项目名称:LittelfuseCatalogs,代码行数:36,代码来源:TableSource.cs

示例8: BeginEditing

        public void BeginEditing(UITableView tableView)
        {
            // Select all.
            for (int i = 0; i < shownCourses.Count; i++)
                tableView.SelectRow(NSIndexPath.FromRowSection((nint)i, 0), true, UITableViewScrollPosition.None);

            var hidden = HiddenPaths();
            tableView.BeginUpdates();
            tableView.InsertRows(hidden, UITableViewRowAnimation.Top);
            shownCourses = courses;
            tableView.EndUpdates();
        }
开发者ID:tsinghua-io,项目名称:learn,代码行数:12,代码来源:CourseListController.cs

示例9: WillBeginTableEditing

		/// <summary>
		/// Called manually when the table goes into edit mode
		/// </summary>
		public void WillBeginTableEditing(UITableView tableView)
		{
			//---- start animations
			tableView.BeginUpdates();

			//---- insert a new row in the table
			tableView.InsertRows(new NSIndexPath[] { NSIndexPath.FromRowSection(tableView.NumberOfRowsInSection(0), 0) }, UITableViewRowAnimation.Fade);
		
			//---- end animations
			tableView.EndUpdates();
		}
开发者ID:Securecom,项目名称:Securecom-Messaging-iOS,代码行数:14,代码来源:CustomCellTableSource.cs

示例10: ReactiveTableViewSource

        public ReactiveTableViewSource(UITableView tableView, IEnumerable<TableSectionInformation> sectionInformation)
        {
            this.tableView = tableView;
            this.sectionInformation = sectionInformation.ToList();

            var compositeDisp = new CompositeDisposable();
            this.innerDisp = compositeDisp;

            for (int i=0; i < this.sectionInformation.Count; i++) {
                var current = this.sectionInformation[i].Collection;

                var section = i;
                var disp = current.Changed.Buffer(TimeSpan.FromMilliseconds(250), RxApp.MainThreadScheduler).Subscribe(xs => {
                    if (xs.Count == 0) return;

                    this.Log().Info("Changed contents: [{0}]", String.Join(",", xs.Select(x => x.Action.ToString())));
                    if (xs.Any(x => x.Action == NotifyCollectionChangedAction.Reset)) {
                        this.Log().Info("About to call ReloadData");
                        tableView.ReloadData();
                        return;
                    }

                    int prevItem = -1;
                    var changedIndexes = xs.SelectMany(x => getChangedIndexes(x)).ToList();
                    changedIndexes.Sort();
                    for(int j=0; j < changedIndexes.Count; j++) {
                        // Detect if we're changing the same cell more than 
                        // once - if so, issue a reset and be done
                        if (prevItem == changedIndexes[j] && j > 0) {
                            this.Log().Info("Detected a dupe in the changelist. Issuing Reset");
                            tableView.ReloadData();
                            return;
                        }

                        prevItem = changedIndexes[j];
                    }

                    this.Log().Info("Beginning update");
                    tableView.BeginUpdates();

                    var toChange = default(NSIndexPath[]);
                    foreach(var update in xs.Reverse()) {
                        switch(update.Action) {
                        case NotifyCollectionChangedAction.Add:
                            toChange = Enumerable.Range(update.NewStartingIndex, update.NewItems != null ? update.NewItems.Count : 1)
                                .Select(x => NSIndexPath.FromRowSection(x, section))
                                .ToArray();
                            this.Log().Info("Calling InsertRows: [{0}]", String.Join(",", toChange.Select(x => x.Section + "-" + x.Row)));
                            tableView.InsertRows(toChange, UITableViewRowAnimation.Automatic);
                            break;
                        case NotifyCollectionChangedAction.Remove:
                            toChange = Enumerable.Range(update.OldStartingIndex, update.OldItems != null ? update.OldItems.Count : 1)
                                .Select(x => NSIndexPath.FromRowSection(x, section))
                                .ToArray();
                            this.Log().Info("Calling DeleteRows: [{0}]", String.Join(",", toChange.Select(x => x.Section + "-" + x.Row)));
                            tableView.DeleteRows(toChange, UITableViewRowAnimation.Automatic);
                            break;
                        case NotifyCollectionChangedAction.Replace:
                            toChange = Enumerable.Range(update.NewStartingIndex, update.NewItems != null ? update.NewItems.Count : 1)
                                .Select(x => NSIndexPath.FromRowSection(x, section))
                                .ToArray();
                            this.Log().Info("Calling ReloadRows: [{0}]", String.Join(",", toChange.Select(x => x.Section + "-" + x.Row)));
                            tableView.ReloadRows(toChange, UITableViewRowAnimation.Automatic);
                            break;
                        case NotifyCollectionChangedAction.Move:
                            // NB: ReactiveList currently only supports single-item 
                            // moves
                            this.Log().Info("Calling MoveRow: {0}-{1} => {0}{2}", section, update.OldStartingIndex, update.NewStartingIndex);
                            tableView.MoveRow(
                                NSIndexPath.FromRowSection(update.OldStartingIndex, section),
                                NSIndexPath.FromRowSection(update.NewStartingIndex, section));
                            break;
                        default:
                            this.Log().Info("Unknown Action: {0}", update.Action);
                            break;
                        }
                    }

                    this.Log().Info("Ending update");
                    tableView.EndUpdates();
                });

                compositeDisp.Add(disp);
            }
        }
开发者ID:jaohaohsuan,项目名称:ReactiveUI,代码行数:85,代码来源:ReactiveTableViewSource.cs

示例11: CommitEditingStyle

 public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
 {
     // check if the edit operation was a delete
     if (editingStyle == UITableViewCellEditingStyle.Delete) {
         
         // remove the customer from the underlying data
         _vc.Customers.RemoveAt (indexPath.Row);
         
         // remove the associated row from the tableView
         tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Middle);
     } else if (editingStyle == UITableViewCellEditingStyle.Insert) {
         _vc.Customers.Add (new Customer ("First", "Last"));
         tableView.InsertRows (new NSIndexPath[] { NSIndexPath.FromRowSection (_vc.Customers.Count - 1, 0) }, UITableViewRowAnimation.None);
     }
 }
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:15,代码来源:CustomersViewController.cs

示例12: RowSelected

        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            tableView.DeselectRow(indexPath, true);

            var node = Nodes[indexPath.Row];
            var children = new List<TreeNode>();
            node.IsExpanded = true;
            if (node.Children.Any())
            {
                children.AddRange(node.Children);

                var isInserted = false;

                foreach (int index in children.Select(child => Nodes.IndexOf(child)))
                {
                    isInserted = (index > 0 && index != int.MaxValue);
                    if (isInserted)
                    {
                        break;
                    }
                }

                var arrayCells = new List<NSIndexPath>();
                if (isInserted)
                {
                    ColapseRow(tableView, children);
                    tableView.ReloadData();
                }
                else
                {
                    var count = indexPath.Row + 1;

                    foreach (var treeNode in children)
                    {
                        treeNode.IsExpanded = false;
                        //if there's  Parent's children not selected remove them
                        var nodesToRemove = new List<TreeNode>();

                        if (treeNode.Parent != null)
                        {
                            if (treeNode.Parent.Children.Any() && treeNode.Parent.Parent != null)
                            {
                                nodesToRemove.AddRange(treeNode.Parent.Parent.Children.Where(x=>!x.IsExpanded));

                                if (nodesToRemove.Any())
                                {
                                    ColapseRow(tableView, nodesToRemove);
                                }
                            }
                        }

                        arrayCells.Add(NSIndexPath.FromRowSection(count, 0));
                        Nodes.Insert(count++, treeNode);
                    }

                    tableView.InsertRows(arrayCells.ToArray(), UITableViewRowAnimation.None);

                    tableView.ReloadData();
                }
            }
        }
开发者ID:MilenPavlov,项目名称:TreeViewSample,代码行数:61,代码来源:TvViewController.cs

示例13: WillBeginTableEditing

 public void WillBeginTableEditing(UITableView tableView)
 {
     tableView.BeginUpdates ();
     // insert the 'ADD NEW' row at the end of table display
     tableView.InsertRows (new NSIndexPath[] {
         NSIndexPath.FromRowSection (tableView.NumberOfRowsInSection (0), 0)
     }, UITableViewRowAnimation.Fade);
     // create a new item and add it to our underlying data (it is not intended to be permanent)
     Item o = new Item ();
     o.Name = "(add new)";
     //			o.imageFileNames = new List<string> ();
     o.ImageFileName = "first.png";
     tableItems.Add (o);
     tableView.EndUpdates (); // applies the changes
 }
开发者ID:KuroiAme,项目名称:Indexer,代码行数:15,代码来源:TableSourceItems.cs

示例14: InsertRows

        private void InsertRows(TreeItem treeItem, UITableView tableView, int selectedItemIndex)
        {
            if (treeItem.Childrens != null) {
                var itemsToInsert = new List<TreeItem> (treeItem.Childrens);
                var itemsToInsertPath = new List<NSIndexPath> ();

                foreach (var item in itemsToInsert) {
                    selectedItemIndex++;
                    _items.Insert (selectedItemIndex, item);
                    itemsToInsertPath.Add (NSIndexPath.FromRowSection (selectedItemIndex, 0));
                }
                tableView.InsertRows (itemsToInsertPath.ToArray (), UITableViewRowAnimation.Bottom);
                treeItem.IsExpanded = true;
            }
        }
开发者ID:sushant3239,项目名称:MultiLevelListView_WP,代码行数:15,代码来源:MyTableViewSource.cs

示例15: WillBeginTableEditing

		/// <summary>
		/// Called manually when the table goes into edit mode
		/// </summary>
		public void WillBeginTableEditing (UITableView tableView)
		{
			//---- start animations
			tableView.BeginUpdates ();
			
			//---- insert a new row in the table
			tableView.InsertRows (new NSIndexPath[] { 
					NSIndexPath.FromRowSection (tableView.NumberOfRowsInSection (0), 0) 
				}, UITableViewRowAnimation.Fade);
			//---- create a new item and add it to our underlying data
			tableItems.Add (new TableItem ("(add new)"));
			
			//---- end animations
			tableView.EndUpdates ();
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:18,代码来源:TableSource.cs


注:本文中的UITableView.InsertRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。