小编sha*_*oor的帖子

UISegmentedControl并添加目标

我相信这对那里的某个人来说很容易.我有一个UISegmentedControl,我用它作为一个按钮(以便不必使用令人讨厌的默认按钮),我无法让目标工作....代码如下

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    //read.buttonType = UIBarStyleBlackOpaque;

    UISegmentedControl* read = [[[UISegmentedControl alloc] initWithFrame:CGRectMake(5, 50, 310, 54)] autorelease];
    [read insertSegmentWithTitle:@"Read" atIndex:0 animated:NO];
    read.tintColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.9 alpha:1];
    read.segmentedControlStyle = UISegmentedControlStyleBar;
    [read addTarget:self action:@selector(changeFilter:sender:) forControlEvents:UIControlEventTouchUpInside];
    [read setTag:1];
    [self.view addSubview:read];



}
Run Code Online (Sandbox Code Playgroud)

然后

-(void)changeFilter:(id)sender{

}
Run Code Online (Sandbox Code Playgroud)

由于某种原因,单击UISegmentedControl不会触发目标方法.

作为附录,是否有更简单的方法来制作漂亮的UIButton?我无法在工作中访问Photoshop(虽然我确实安装了gimp),因此一种不涉及图像制作的方法会很好.我无法相信苹果在UI中没有提供漂亮的UIButton,这似乎是一个需要的基本要素?

无论如何,感谢帮助误区友.

谢谢你的答案...我已经尝试了修复,但它仍然没有解决

我现在有

[read addTarget:self action:@selector(changeFilter:) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)

然后

@interface
-(void)changeFilter:(id)sender;
Run Code Online (Sandbox Code Playgroud)

@implementation
-(void)changeFilter:(id)sender{}
Run Code Online (Sandbox Code Playgroud)

请注意,该方法与UISegmentedControl属于同一个类.也许我应该尝试使用建议的Glass按钮API,但是我的老板讨厌我使用第三方库,如果有办法避免它!

iphone objective-c uibutton ipad ios

6
推荐指数
2
解决办法
5237
查看次数

相同gzip压缩文件的Python md5哈希值不一致

我正在尝试使用python模块gzip压缩文件,然后使用hashlib对gzip归档的文件进行哈希处理。我有以下代码:

import hashlib
import gzip

f_name = 'read_x.fastq'

for x in range(0,3):

    file = open(f_name, 'rb')

    myzip = gzip.open('test.gz', 'wb', compresslevel=1)

    n = 100000000
    try:
        print 'zipping ' + str(x)
        for chunk in iter(lambda: file.read(n), ''):
            myzip.write(chunk)
    finally:
        file.close()
        myzip.close()

    md5 = hashlib.md5()
    print 'hashing ' + str(x)
    with open('test.gz', 'r') as f:
        for chunk in iter(lambda: f.read(n), ''):
            md5.update(chunk)

    print md5.hexdigest()
    print '\n'
Run Code Online (Sandbox Code Playgroud)

我认为应该简单地压缩文件,对其进行哈希处理并连续显示三次相同的输出哈希。但是,我得到的输出是:

zipping 0
hashing 0
7bd80798bce074c65928e0cf9d66cae4


zipping 1
hashing 1
a3bd4e126e0a156c5d86df75baffc294


zipping 2
hashing 2
85812a39f388c388cb25a35c4fac87bf …
Run Code Online (Sandbox Code Playgroud)

python hash gzip md5

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

C++ 包含问题

我正在使用 C++ 为 Autodesk Maya 编写一个插件,但出现链接器错误。

我的主类是 Maya_Search_Plugin.cpp

#include <Utilities.h>

DeclareSimpleCommand( search_face, PLUGIN_COMPANY, "4.5");

//doIt method is entry point for plugin
MStatus search_face::doIt( const MArgList& )
{
    //calls to Maya types/functions and Utilities functions
}
Run Code Online (Sandbox Code Playgroud)

然后我有一个实用程序类,其中包含一些静态方法,其标头如下所示

#ifndef __Maya_CPP_Plugin__Utilities__
#define __Maya_CPP_Plugin__Utilities__
//#pragma once

//standard libs
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <math.h>

//maya libs
#include <maya/MDagPath.h>
#include <maya/MFn.h>
#include <maya/MFileIO.h>
#include <maya/MIOStream.h>
#include <maya/MFnMesh.h>
#include <maya/MFnTransform.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionList.h>
#include <maya/MSimple.h>
#include <maya/MTypes.h>
#include <maya/MPointArray.h>
#include <maya/MObjectArray.h> …
Run Code Online (Sandbox Code Playgroud)

c++ include maya

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

标签 统计

c++ ×1

gzip ×1

hash ×1

include ×1

ios ×1

ipad ×1

iphone ×1

maya ×1

md5 ×1

objective-c ×1

python ×1

uibutton ×1