问题列表 - 第19751页

当单击editButtonItem时,不会显示红色删除图标

我现在正在写一个IPhone IM聊天窗口.

您知道如果UITableviewController中的nagviationItem.rightBarItem设置为editButtonItem,则单击编辑按钮,然后会向每一行显示一个红色删除图标, 如此处所示.

问题是,我有一个UIViewController而不是UITableViewController:

@interface ChatUIViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{
    UITableView *table;
    UITextField *textField;
Run Code Online (Sandbox Code Playgroud)

}

我做了相同的设置editButtonItem:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.rightBarButtonItem = self.editButtonItem;
Run Code Online (Sandbox Code Playgroud)

}

当我单击编辑按钮时,红色删除图标将不会显示.

如何制作ChatUIViewController中显示的红色删除图标?

提前感谢任何可能提供帮助的人.迈克尔

iphone rightbarbuttonitem

8
推荐指数
1
解决办法
4145
查看次数

NSNumber numberWithInt:返回奇怪的数字?

我刚开始使用Core Data并遇到了一个需要使用适当的ID保存新对象的问题.

我正在尝试将行中的下一个数字添加为用户添加的对象的ID:

NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"Favorites" inManagedObjectContext:managedObjectContext]];
[request setIncludesSubentities:NO];
NSError *err;
NSUInteger count = [managedObjectContext countForFetchRequest:request error:&err];

NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[fetchedResultsController fetchRequest] entity];
NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];

[newManagedObject setValue:[NSNumber numberWithInt:count] forKey:@"favoritesID"];
Run Code Online (Sandbox Code Playgroud)

如果我然后去获取valueForKey:@"favoriteID"我会得到类似"81933072"的内容,这是错误的.

我已经检查过count它是正确的数字,只是当我把它放入Core Data时它变成了别的东西.favoriteID是一个int16顺便说一句.

iphone core-data nsnumber

2
推荐指数
1
解决办法
6165
查看次数

使用jQuery发出.NET Ajax请求

我只是想知道的是,反正是有使用jQuery("$阿贾克斯"),使局部呈现而不使用.NET Ajax框架(无脚本管理器),使Ajax请求.

我之前尝试过这个,但它page_load每次都在执行,而没有达到页面方法.

function doAsync() 
{ 
   jQuery.ajax({ 
   type: "POST", 
   url: "/WebForm1.aspx/testMethod", 
   error: function (xhr, status, error) { alert(status); }, 
   success: function (response) { alert('suc'); }
   )};
}

 [WebMethod] 
 public static void testMethod() 
 {
     //server side code 
 } 
Run Code Online (Sandbox Code Playgroud)

这里有什么不对吗?

谢谢!

asp.net jquery

2
推荐指数
1
解决办法
2733
查看次数

在C中删除内存

如何删除C中的内存?

例如,我有:

#include<stdlib.h>
#include<stdio.h>

struct list_el {
   int val;
   struct list_el * next;
};

typedef struct list_el item;

void main() {
   item * curr, * head;
   int i;

   head = NULL;

   for(i=1;i<=10;i++) {
      curr = (item *)malloc(sizeof(item));
      curr->val = i;
      curr->next  = head;
      head = curr;
   }

   curr = head;

   while(curr) {
      printf("%d\n", curr->val);
      curr = curr->next ;
   }
}
Run Code Online (Sandbox Code Playgroud)

在我创建项目1 - 10后,如何删除它并确保它不存在于内存中?

c

5
推荐指数
1
解决办法
9831
查看次数

Eclipse是否显示了扩展当前类的类列表

我很想知道eclipse是否具有显示扩展当前类的所有类列表的功能.这个功能在INTELLIJ中提供.任何想法.

eclipse

5
推荐指数
3
解决办法
4690
查看次数

使用Moq和Unity对Mock存储库对象进行单元测试的正确方法

在我的工作中,我们使用Moq进行模拟,使用Unity作为IOC容器.我对此很新,并且没有很多资源可以帮助我确定我应该使用的最佳实践.

现在,我有一组特定进程需要用来完成其工作的存储库接口(例如:IRepository1,IRepository2 ... IRepository4).

在实际代码中,我可以使用IOC容器并使用RegisterType()方法确定所有IRepository对象.

我试图找出能够测试需要4个提到的存储库的方法的最佳方法.

我想我可以只注册一个Unity IOC容器的新实例,并在每个模拟对象的容器上调用RegisterInstance,为每个模拟对象传递Mock.Object值.我试图使这个注册过程可重用,所以除了单元测试需要从存储库返回一些特定数据之外,我不必一遍又一遍地对每个单元测试做同样的事情.这就是问题所在......在模拟存储库上设置期望值的最佳做法是什么?好像我只是在Unity容器上调用RegisterType,我将失去对实际Mock对象的引用,并且无法覆盖行为.

.net c# moq unity-container

35
推荐指数
1
解决办法
4万
查看次数

如何识别我在视频帧中检测到的对象是人还是汽车

我在检测图像或视频帧中的对象时遇到问题.

我有一个任务是检测到某些人或某些进入网络摄像头的东西,然后我的系统将报警.

下一步是识别对象是哪种东西,在这个阶段我知道使用Hough变换来检测线,圆,甚至矩形.但当人们看到相机时,人们的轮廓比线条,圆形和矩形更复杂.我怎么能认出对象是人不是车.

我需要帮助才能知道.提前致谢

machine-learning image-processing computer-vision

2
推荐指数
1
解决办法
3296
查看次数

Delphi循环速度问题

有更快的方法吗?我基本上需要一次将AA-ZZ添加到数千条记录中.

只需要35个项目的列表就需要很长时间才能完成一千个列表.


procedure Tmainform.btnSeederClick(Sender: TObject);
var
  ch,ch2:char;
  i:integer;
  slist1, slist2:TStrings;
begin
  slist1:= TStringList.Create;
  slist2:= TStringList.Create;
  slist1.Text :=queuebox.Items.Text;
  for ch := 'a' to 'z' do
    begin
      for ch2 := 'a' to 'z' do
        begin
          //

for I := 0 to slist1.Count - 1 do begin application.ProcessMessages; // so it doesn't freeze the application in long loops. Not 100% sure where this should be placed, if at all. sleep(1); //Without this it doesn't process the cancel button. if cancel then Break; slist2.Add(slist1.Strings[i]+ch+ch2); …
Run Code Online (Sandbox Code Playgroud)

delphi performance loops for-loop

5
推荐指数
4
解决办法
3664
查看次数

Visual Basic循环并一次显示一行

我正在使用Visual Studio 2008,VB9,我正在尝试编写一个基本上对用户输入的一组数据进行计算的应用程序.在计算过程中,我想在每一步显示数据,并将其保留在GUI的显示区域(不会被显示的下一个数据覆盖).

例如:

UserInput = 1

Do

  UserInput += 1

  OutputLabel.Text = "UserInput " & UserInput

Loop Until UserInput = 5
Run Code Online (Sandbox Code Playgroud)

输出看起来像

UserInput 1 UserInput 2 UserInput 3 UserInput 4 UserInput 5

我试过这个,以及其他循环结构,似乎无法把事情做对.实际的应用程序有点复杂,但该示例很适合逻辑用途.

欢迎任何提示,谢谢!

vb.net string visual-studio-2008

5
推荐指数
1
解决办法
6659
查看次数

声明说明符中的两个或多个数据类型错误

我对C.很新.

我收到此错误:

内置函数'malloc'的不兼容隐式声明

即使我根据包含的答案修复代码<stdlib.h>,我仍然得到:

声明说明符中的两个或多个数据类型

尝试这样做时:

struct tnode
{
    int data;
    struct tnode * left;
    struct tnode * right;
}

struct tnode * talloc(int data){
    struct tnode * newTnode;
    newTnode = (struct tnode *) malloc (sizeof(struct tnode));
    newTnode->data = data;
    newTnode->left = NULL;
    newTnode->right = NULL;
    return newTnode;
}
Run Code Online (Sandbox Code Playgroud)

我如何解决它?

c

33
推荐指数
2
解决办法
8万
查看次数