вторник, 24 июля 2012 г.

How to delete a row in UITableView manually?

To delete row from table manually (programmatically) at first remove items from array with table items, which you use to build table cells. Then you should use method

[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
Where instead of
[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]]
you should use your array with index paths. Here just first row will be removed.
And don't forget to wrap this method into
[self.tableView beginUpdates];
...
[self.tableView endUpdates];
So in conclusion this code should looks like this

понедельник, 23 июля 2012 г.

Change frame size for modal controller with modalPresentationStyle = UIModalPresentationFormSheet

ARC version
ModalViewController *targetController = [[ModalViewController alloc] init];
targetController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:targetController animated:YES];
targetController.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after presentModalViewController
targetController.view.superview.center = self.view.center;//self.view assumes the base view is doing the launching, if not you might need self.view.superview.center etc.
None ARC
ModalViewController *targetController = [[[ModalViewController alloc] init] autorelease];
targetController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:targetController animated:YES];
targetController.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after presentModalViewController
targetController.view.superview.center = self.view.center;//self.view assumes the base view is doing the launching, if not you might need self.view.superview.center etc.
see on stackoverflow.com

четверг, 19 июля 2012 г.

How to switch UIsegmentedControll programmatically

// select the first segment
segmented.selectedSegmentIndex = 0;

// turn off the current selection
segmented.selectedSegmentIndex = UISegmentedControlNoSegment;

вторник, 17 июля 2012 г.

How to force update git

git fetch --all 
git reset --hard origin/master
Git fetch downloads the latest from remote without trying to merge or rebase anything. 
Then the git reset resets the master branch to what you just fetched.

понедельник, 12 сентября 2011 г.

Переопределени блока кастомного модуля

Чтобы переопрелелить поведение блока кастомного модуля необходимо.

  1. Создать модуль
  2. Переопределить блок своим блоком.

Итак приступим.
Для начала создадим в папке app/etc/modules xml файл с объявлением нашего модуля. Файл будет называться MyNameSpase_Blog.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <MyNameSpase_Blog>
            <!-- Add this to easy revriew block in module config xml -->
            <depends><AW_Sarp /></depends>
            <active>true</active>
            <codePool>local</codePool>
        </MyNameSpase_Blog>
    </modules>
</config>
Обратите внимание на строку с тегами depends. Мы добавляем ее для более простого обращения к модулю в config.xml нашего модуля. Так же это дает нам уверенность в том, что наш модуль будет загружен после модуля AW_Sarp. Теперь переместимся в config.xml нашего модуля. Он должен находится в app/code/local/MyNameSpase/Blog/etc. Вот его содержимое
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <MyNameSpase_Blog>
            <version>0.1.0</version>
        </MyNameSpase_Blog>
    </modules>
    <global>
        <blocks>
            <blog>MyNameSpase_Blog_Block</blog>
            <sarp>
                <rewrite>
                    <customer_subscription_list>MyNameSpase_Blog_Block_Customer_Subscription_List</customer_subscription_list>
                </rewrite>
            </sarp>
        </blocks>
    </global>
</config>
Мы собираемся переопределить блок AW_Sarp_Customer_Subscription_List на наш MyNameSpase_Blog_Block_Customer_Subscription_List, который должен лежать в app/code/local/MyNameSpase/Blog/Block/Customer/Subscription/List.php. Как видите из-за того, что мы указали
<depends><aw_sarp/></depends>
нам нет необходимости обращаться к блоку указывая его модуль.
Happy coding!

среда, 23 марта 2011 г.

Как добавить свой статус для заказа в Magento 1.4

Как вы знаете Magento по умолчанию предоставляет следующие статусы для заказа.

  1. Pending
  2. Processing
  3. Complete

Просмотрев форум Magento удалось найти решения с помощью хаков. Но это не наш путь ! :D
Я покажу вам как можно с помощью простого модуля добавить свои статусы для заказа.