我阅读了关于表视图和它的编辑样式,但我遇到了一些问题,因为只有三种编辑风格如下:
UITableViewCellEditingStyleNoneUITableViewCellEditingStyleDeleteUITableViewCellEditingStyleInsert我想重新排序我使用它的委托成功实现的tableview单元格.
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
return YES;
}
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return UITableViewCellEditingStyleNone;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
//handle the editing style
}
-(NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath{
//move cells
}
-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{
return YES;
}
Run Code Online (Sandbox Code Playgroud)
我不想使用UITableViewCellEditingStyleDelete它,因为它在表视图上显示一个红色的圆形按钮.而不是这个,我想要一起刷卡到删除和重新排序功能.
有没有办法实现这个?
我正在尝试在我的详细信息组件中使用我的主要组件中的一个函数,我用户反应导航导航到该函数,并且我想在我的主要组件中保存详细信息屏幕中的一些更改
//主.js
import React from 'react';
import {
StyleSheet ,
Text,
View,
TextInput,
ScrollView,
TouchableOpacity,
KeyboardAvoidingView,
AsyncStorage
} from 'react-native'
import Note from './Note'
import { createStackNavigator, createAppContainer } from "react-navigation";
import Details from './Details';
export default class Main extends React.Component {
static navigationOptions = {
title: 'To do list',
headerStyle: {
backgroundColor: '#f4511e',
},
};
constructor(props){
super(props);
this.state = {
noteArray: [],
noteText: ''
};
}
render() {
let notes = this.state.noteArray.map((val,key) => {
return <Note key={key} keyval={key} val={val} …Run Code Online (Sandbox Code Playgroud)